<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--MD5工具类-->
    <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js"></script>
</head>
<body>
<!--表单绑定提交事件 onsubmit绑定一个提交检测的函数 true  false
    将这个结果返回表单 使用onsubmit接收
-->
<form action="https://www.baidu.com/" method="post" onsubmit="return check()">
    <p><span>用户名： </span><input type="text" id="username" name = "username" required></p>
    <p><span>密  码：</span><input type="password"  id="input-password" required></p>
    <input type="hidden" id="md5-password" name="password">
    <!--绑定事件 onclick-->
    <!-- <button type = "submit" onclick="check()">提 交</button> -->
    <input type="submit" >
</form>

<script>
    function check(){
        alert('进入');
        var uname = document.getElementById("username");
        var pwd  = document.getElementById("input-password");
        var md5pwd  = document.getElementById("md5-password");
        console.log(uname.value);
        //MD5算法
        //pwd.value = md5(pwd.value);
        //console.log(pwd.value);
        md5pwd.value = md5(pwd.value);
        //可以校验表单内容 true同意提交 false阻止提交
        return true;
    }
</script>
</body>
</html>